Improve facet error messages in animint2dir#285
Conversation
Issue #168 - facet_wrap(. ~ var) gives unhelpful error when var is missing. Added tests that will pass once we improve error messages in animint2dir(). Tests cover facet_wrap and facet_grid with missing variables. These tests are animint2-specific .
When facet_wrap or facet_grid uses formula notation with a variable that does not exist in the data, the error now shows: - Which variable is missing - What columns are available - Suggests using string notation instead Fixes #168
Before :-
After :- |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #285 +/- ##
==========================================
+ Coverage 73.34% 73.37% +0.02%
==========================================
Files 164 164
Lines 8861 8870 +9
==========================================
+ Hits 6499 6508 +9
Misses 2362 2362
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
No obvious timing issues in HEAD=fix-168-facet-error-message Generated via commit c1877ef Download link for the artifact containing the test results: ↓ atime-results.zip
|
|
Sir @tdhock The 2 failing tests in JS_coverage are in test-compiler-ghpages.R (GitHub Pages tests), not related to this PR. This is the same race condition issue where parallel CI jobs conflict over the shared test repository. All facet-related tests pass:
The fix is working correctly. Please review and give your feedback Sir . |
| # variables that appear in the data | ||
| has_all <- unlist(plyr::llply(values, length)) == length(vars) | ||
| if (!any(has_all)) { | ||
| vars_to_check <- vars[vars != "."] |

FIXES #168
What's broken
Error: At least one layer must contain all variables used for facettingDoesn't tell you what's wrong or how to fix it.
facet_wrap("Species") # string notation works fineWhat I am fixing
Next commit will add the fix to make tests pass.